<template>
	<view>
		<button type="default" @click="img">点我</button>
		<image :src="picture" mode=""></image>
		<button type="default" @click="getToken">获取token</button>
		{{token}}
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token : "",
				picture:""
			}
		},
		methods: {
			img(){
				uni.chooseImage({
				    count: 6, //默认9
				    sizeType: 'compressed', //可以指定是原图还是压缩图，默认二者都有
				    success:  res=> {
				        console.log(res.tempFilePaths[0]);
						this.picture = res.tempFilePaths[0]
				    }
				});
				
			},
			getToken(){
				uni.request({
				            url:"https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=GAHBzTvBXZEv1X9RzExMV3Cj&client_secret=4fUHGTGcUCLI48AvR30Fkv7fLeew8SPj",  
				            method: 'POST',
							withCredentials: true,
				            success: res => {  
				              console.log(res.data.access_token)
							   this.token = res.data.access_token
				            }  
				        })  
			}
		}
	}
</script>

<style>

</style>
